<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<title>资产管理系统 - 企业级统一化开发平台</title>
	<link rel="shortcut icon" href="http://training-static.linesno.com/switch_run/favicon.ico" />
	<link href="http://training-static.linesno.com/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link href="https://v4.bootcss.com/docs/4.0/examples/floating-labels/floating-labels.css" rel="stylesheet">

	<style type="text/css">
	.form-control {
		height: auto !important;
	}
	</style>
</head>

<body>
	<form class="form-signin">
		<div class="text-center mb-4">
			<h1 class="h3 mb-3 font-weight-normal">管理员登陆</h1>
			<p>资产管理系统</p>
		</div>

		<div class="form-label-group">
			<input type="text" name="loginName" id="inputEmail"
				class="form-control" placeholder="账号" required autofocus> <label
				for="inputEmail">账户</label>
		</div>

		<div class="form-label-group">
			<input type="password" name="password" id="inputPassword"
				class="form-control" placeholder="密码" required> <label
				for="inputPassword">密码</label>
		</div>

		<div class="checkbox mb-3">
			<label> <input type="checkbox" value="remember-me">
				记住我
			</label>
		</div>

		<button class="btn btn-lg btn-primary btn-block" onclick="doValidate(this)" type="button">登陆</button>
		<p class="mt-5 mb-3 text-muted text-center">&copy; 2019-2020</p>
	</form>

	<script src="http://training-static.linesno.com/vendor/jquery/jquery.min.js"></script>
	<script type="text/javascript">
			document.onkeydown=function(event){   
				var e = event || window.event || arguments.callee.caller.arguments[0];   
				if(e && e.keyCode==13){ // enter 键   
					doValidate(null) ; 
				}  
			};    
			
	  		var doing = false ; 
	  		function doValidate(btn){
	  			if(doing){
	  				return ; 
	  			}
	  			var _loginName = $("input[name=loginName]").val() ; 
	  			var _password = $("input[name=password]").val() ; 
	  			doing = true ; 
	  			
	  			$.post("/manager/validate" , {loginName:_loginName , password:_password} , function(response){
	  				console.log("response = " + response) ; 
	  				doing = false ; 
	  				if(response.code == 400){
	  					alert(response.message) ; 
	  				}else if(response.code == 200){
	  					console.log("登陆成功.") ; 
	  					self.location="/manager/dashboard" ; 
	  				}
	  			}) ; 
	  		}
	  </script>
</body>
</html>

